# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2021年12月23日
"""
from sklearn.linear_model import Ridge
import numpy as np
import pandas as pd

data = [[56, 7800], [104, 9000], [156, 9200], [200, 10000], [250, 11000], [300, 12000]]
columns = ['面积', '价格']
df = pd.DataFrame(data=data, columns=columns)
X = pd.DataFrame(df['面积'])
y = pd.DataFrame(df['价格'])
clf = Ridge(alpha=1.0)
clf.fit(X, y)  # 拟合线性模型
k = clf.coef_
b = clf.intercept_
x0 = np.array([[170]])
print(x0)
y0 = clf.predict(x0)
print('回归系数:', k)
print('截距:', b)
print('预测值', y0)
